package com.qumitech.visualnovel.controller.rest;

import com.qumitech.visualnovel.console.excel.ExportExcel;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.pubdef.dto.gift.GiftBaseConfigSortedDTO;
import com.qumitech.visualnovel.pubdef.dto.gift.UserGiftDetailAdminQueryDTO;
import com.qumitech.visualnovel.pubdef.dto.gift.UserGiftPresentStatisticsAdminQueryDTO;
import com.qumitech.visualnovel.service.gift.GiftService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author :  ZhChNing
 * @Descriptiom :
 * @Date Created in 2019/9/18 10:42
 */

@RestController
@RequestMapping("/api/gift")
public class GiftAdminController {
    @Autowired
    private GiftService giftService;

    //@RequireWhiteList
    @GetMapping("/receive/detail")
    @ExportExcel(listKey = "receive_detail.present_gift_list", itemKeys = {"fromUid","fromUserName","toUid","toUserName","authorId","createTime","giftName","costType","giftOriginFromType","shopGiftNum","shopGiftCost","eggGiftNum","eggGiftCost","giftNum","cost"},
    itemNames = {"送礼人ID","送礼人昵称","收礼人ID","收礼人昵称","主播ID","赠送时间","礼物名称","礼物类型","礼物来源","商城礼物数量","商城礼物价值","滴滴礼物数量","滴滴礼物价值","数量","价值"})
    public BaseRsp listGiftDetailAdminDTO(UserGiftDetailAdminQueryDTO queryDTO) {
        return new BaseRsp(ResultEnum.SUCCESS, giftService.listGiftDetailAdminDTO(queryDTO));
    }

    @PostMapping("/receive/detail/import")
    public BaseRsp listGiftDetailAdminDTOImport(@RequestBody UserGiftDetailAdminQueryDTO queryDTO, HttpServletResponse request) {
        giftService.exportMultipartFile(queryDTO, request);
        return new BaseRsp(ResultEnum.SUCCESS);
    }

    @GetMapping("/config/list")
    public BaseRsp listGiftBaseConfig() {
        return new BaseRsp(ResultEnum.SUCCESS, giftService.listGiftBaseConfig());
    }


    @GetMapping("/change/statistics")
    public BaseRsp statistics(UserGiftPresentStatisticsAdminQueryDTO queryDTO) {
        return   giftService.getStatistics(queryDTO);
    }

    @GetMapping("/priority")
    public BaseRsp getGiftPriority() {
        return giftService.getGiftPriority();
    }

    @PutMapping("/priority")
    public BaseRsp editGiftPriority(@RequestBody List<GiftBaseConfigSortedDTO> sortedDTOS) {
        return giftService.editGiftPriority(sortedDTOS);
    }
}